import fetch from '../common/httpRequest'

// #ifndef VUE3
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const store = new Vuex.Store({
      // #endif

      // #ifdef VUE3
      import {
        createStore
      } from 'vuex'
      const store = createStore({
        // #endif
        state: {
          token: uni.getStorageSync('token') || null,
          userInfo: {},
          SelfUserInfo: {}
        },
        mutations: {
          setToken(state,token) {
            state.token = token;
            uni.setStorageSync('token', token);
          },
          setUserInfo(state,userInfo) {
            state.userInfo = userInfo;
            uni.setStorageSync('userInfo', userInfo);
          },
          setSelfUserInfo(state,SelfUserInfo) {
            state.SelfUserInfo = SelfUserInfo;
            uni.setStorageSync('SelfUserInfo', SelfUserInfo);
          },
          clearUserInfo(state) {
            state.token = '';
            state.userInfo = {};
            uni.clearStorage();
          }
        },
        actions: {

        }
      })

      export default store